home *** CD-ROM | disk | FTP | other *** search
- /*******************************************************************************
- * Copyright © 1992-1993 Mark Pilgrim *
- * *
- * This file is provided as is, and may be freely distributed unaltered. This *
- * message must accompany any copy of this file. This file may be used or *
- * modified for use for a non-commercial product provided that appropriate *
- * credit is given to the author named above. *
- * Commercial use of this source code is prohibited. *
- ******************************************************************************/
-
- #include "msg misc.h"
- #include "msg timing.h"
-
- #define gap 4 /* difference between one radius and the next */
- #define StartRadius 300 /* should be just over || (cx,cy) || */
- #define CorrectTime 2
-
- void CircleIn(GrafPtr);
-
- /* Take a really big circle, then a slightly smaller circle (-gap), then
- take the region in between them and copy that, then decrease the outer
- circle radius by gap. Thus: circle in, by successive donut-like copies. */
-
- void CircleIn(GrafPtr sourceGrafPtr)
- {
- Rect theRect;
- Rect source;
- int cx, cy;
- RgnHandle curregion,lastregion,diffregion;
-
- cx = MAIN_WINDOW_WIDTH / 2;
- cy = MAIN_WINDOW_HEIGHT / 2;
-
- theRect.left=cx-StartRadius; /* circumscribing rectangle for outer circle */
- theRect.right=cx+StartRadius;
- theRect.top=cy-StartRadius;
- theRect.bottom=cy+StartRadius;
-
- source.top=source.left=0;
- source.bottom=MAIN_WINDOW_HEIGHT;
- source.right=MAIN_WINDOW_WIDTH;
-
- curregion=NewRgn();
- lastregion=NewRgn();
- diffregion=NewRgn();
-
- SetEmptyRgn(lastregion);
- OpenRgn();
- FrameOval(&theRect); /* first circle */
- CloseRgn(lastregion);
-
- while (theRect.right-theRect.left>0)
- {
- StartTiming();
- theRect.left+=gap;
- theRect.right-=gap;
- theRect.top+=gap;
- theRect.bottom-=gap;
- SetEmptyRgn(curregion);
- OpenRgn();
- FrameOval(&theRect); /* inner circle */
- CloseRgn(curregion);
- DiffRgn(lastregion,curregion,diffregion); /* donut we need */
- CopyBits(&(sourceGrafPtr->portBits), &(gMainWindow->portBits),
- &source, &source, 0, diffregion);
- CopyRgn(curregion,lastregion); /* outer circle = inner circle */
- TimeCorrection(CorrectTime);
- }
-
- DisposeRgn(curregion);
- DisposeRgn(lastregion);
- DisposeRgn(diffregion);
- }
-